import request from '../utils/request';

/**
 * @description: 用户登录
 * @param {API} data
 * @param {any} options
 * @return {*}
 */
export const toLogin = (data: API.LoginReq, options?: any) => {
    return request({
        method: 'POST',
        url: '/api/v1/app_users/login',
        data
    }, options)
}

/**
 * @description: 获取邮箱验证码
 * @param {object} params
 * @param {any} options
 * @return {*}
 */
export const sendMailer = (params: { email: string }, options?: any) => {
    return request({
        method: 'GET',
        url: '/api/v1/sendMailer',
        params
    }, options)
}

/**
 * @description: 获取图片验证码
 * @param {any} options
 * @return {*}
 */
export const getCaptchaCode = (options?: any) => {
    return request({
        method: 'GET',
        url: '/api/v1/getCaptchaCode',
    }, options)
}

/**
 * @description: app用户注册
 * @param {API} data
 * @param {any} options
 * @return {*}
 */
export const appRegister = (data: API.RegisterReq, options?: any) => {
    return request({
        method: 'POST',
        url: '/api/v1/app_users/register',
        data
    }, options)
}

/**
 * @description: 邮箱验证
 * @param {object} data
 * @param {any} options
 * @return {*}
 */
export const toVerifyEmail = (data: { email: string, code: string, is_reg?: number }, options?: any) => {
    return request({
        method: 'POST',
        url: '/api/v1/emailVerify',
        data
    }, options)
}

/**
 * @description: 上传文件
 * @param {object} params
 * @param {any} data
 * @return {*}
 */
export const uploadFile = (params: { single: number, category: string}, data: any, options?: any) => {
    return request({
      url: '/api/v1/file',
      method: 'POST',
      headers: { "Content-Type": "multipart/form-data" },
      params,
      data,
    }, options);
  }
  